<template>
  <div class="news">
    <!--导航区-->
    <ul>
      <li v-for="news in newList" :key="news.id">
        <!--第一种写法-->
        <!--<RouterLink :to="`/news/detail?id=${news.id}&title=${news.title}&contnent=${news.content}`">{{news.title}}</RouterLink>-->

        <!--第二种写法-->
        <RouterLink
            :to="{
              path:'/news/detail',
              query:{
                id:news.id,
                title:news.title,
                content:news.content
              }
        }">
          {{news.title}}
        </RouterLink>
      </li>
    </ul>
    <!--展示区-->
    <div class="news-content">
      <RouterView></RouterView>
    </div>
  </div>
</template>

<script setup lang="ts" name="News">
  import {reactive} from "vue";
  import { RouterView,RouterLink } from "vue-router";

  const newList = reactive([
    {id:'key01', title:'很好的抗癌食物', content:'西兰花'},
    {id:'key02', title:'如何掌握全栈', content:'学vue'},
    {id:'key03', title:'尽快完成任务', content:'明天是周二'},
    {id:'key04', title:'洛杉矶山火', content:'继续烧'}
  ])
</script>

<style scoped>
/* 新闻 */
.news {
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  height: 100%;
}
.news ul {
  margin-top: 30px;
  //list-style: none;
  padding-left: 10px;
}
.news li>a {
  font-size: 18px;
  line-height: 40px;
  text-decoration: none;
  color: #64967E;
  text-shadow: 0 0 1px rgb(0, 84, 0);
}
.news-content {
  width: 70%;
  height: 90%;
  border: 1px solid;
  margin-top: 20px;
  border-radius: 10px;
}
</style>